﻿using System;
using System.Diagnostics;
using Budget.DataBase;
using NH.Core.Interfaces;
using NHibernate;
using NHibernate.Cfg;

namespace NH.Data
{
    public static class DB
    {
        private static ISessionFactory factory;

        public static ISessionFactory Factory
        {
            get { return factory; }
        }

        public static void Init<T>(T config) where T : IConfig<Configuration>
        {
            var configuration = config.GetConfig();
            factory = configuration.BuildSessionFactory();
        }

        public static void Migrate(string db, string con)
        {
            //try
            //{
            //    BudgetMigrator.Migrate(db, con);
            //}
            //catch (Exception ex)
            //{
            //    Trace.TraceError(ex.Message);
            //}
        }
    }
}